package io.renren.modules.model.service.impl;

import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;

import io.renren.modules.model.dao.ModelEquipmentInfoDao;
import io.renren.modules.model.entity.ModelEquipmentInfoEntity;
import io.renren.modules.model.service.ModelEquipmentInfoService;


@Service("modelEquipmentInfoService")
public class ModelEquipmentInfoServiceImpl extends ServiceImpl<ModelEquipmentInfoDao, ModelEquipmentInfoEntity> implements ModelEquipmentInfoService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
    	
    	// 根据pid查询
    	String pid = (String) params.get("pid");
    	
        Page<ModelEquipmentInfoEntity> page = this.selectPage(
                new Query<ModelEquipmentInfoEntity>(params).getPage(),
                new EntityWrapper<ModelEquipmentInfoEntity>()
                	.like(StringUtils.isNotBlank(pid), "pid", pid)
        );

        return new PageUtils(page);
    }
    
    @Override
    public List<ModelEquipmentInfoEntity> queryEqmForPid(Map<String, String> params){
    	String pid = params.get("pid");
		return baseMapper.queryEqmForPid(Long.parseLong(pid));
    }

}
